#pragma once

#include "Object.h"
#include "String.h"

namespace BaseType
{

class BASE_TYPE_API Integer : public OType
{
public:

    static Integer* GetZeroInt();
    static Integer* GetPosInt(uint16_t index);
    static Integer* GetNegInt(int16_t index);

    RTTIOfClass(Integer)

    Integer() : _value(0) {}
    Integer(int32_t value, bool autodel) : _value(value) 
    { 
        setAutoDelete(autodel); 
    }

    Integer(int32_t value) : _value(value) {}
    Integer(const String& value);
    Integer(const String& value, int32_t iDef);

    int32_t ToInt();
    float ToFloat();
    String ToString();

    bool Equals(Object* Other);
    int GetHashCode() const;

    void SetInteger(int32_t val);
    Integer& operator=(const Integer& Other);

    operator int32_t() { return _value; }
    bool operator<(const Integer& Other) { return _value < Other._value; }
    bool operator==(const Integer& Other) { return _value == Other._value; }
    bool operator!=(const Integer& Other) { return _value != Other._value; }
    bool operator>(const Integer& Other) { return _value > Other._value; }

protected:

    static bool _initInteger;
    static Integer* ZeroInteger;
    static Integer* PosInteger[16];
    static Integer* NegInteger[16];

protected:

    int32_t _value;
};

class BASE_TYPE_API IntegerType : public Object
{
public:

    IntegerType() 
        : _value(0)
        , Object(false) 
    {}

    IntegerType(int value) 
        : _value(value)
        , Object(false) 
    {}

    int GetHashCode() const { return (int)_value;}
    int32_t ToInt() { return _value; }
    String ToString();

    bool operator==(const IntegerType& Other)
    {
        return _value == Other._value;
    }

    operator int32_t() { return _value; }

protected:

    int32_t _value;
};

}
